package com.itheima_06;

import java.io.*;
import java.net.Socket;

public class ClinetTest1 {
    public static void main(String[] args) throws IOException {
        File file = new File("C:\\Users\\wfsxy\\Desktop\\新建文件夹");
        File[] files = file.listFiles();
        for (int i = 0; i < files.length; i++) {
            File file1 = files[i];
            //String name = file1.getName();
            FileInputStream fis = new FileInputStream(file1);
            BufferedInputStream bis = new BufferedInputStream(fis);
            Socket socket = new Socket("192.168.14.41", 10000);
            OutputStream os = socket.getOutputStream();
            BufferedOutputStream bos = new BufferedOutputStream(os);
            byte[] bys = new byte[1024];
            int len;
            while ((len = bis.read(bys)) != -1) {
                bos.write(bys, 0, len);
                bos.flush();

            }
            socket.shutdownOutput();

            InputStream is = socket.getInputStream();
            InputStreamReader isr = new InputStreamReader(is);
            BufferedReader br = new BufferedReader(isr);
            String line;
            while ((line = br.readLine()) != null) {
                System.out.print(line);
            }
            bis.close();
            socket.close();
        }

        //socket.shutdownInput();


    }
}
